package com.algorithms;

import com.algorithms.hash.ChainHashTable;
import com.algorithms.hash.DoubleHashTable;
import com.algorithms.utils.Utils;

public class test_hash extends Thread {
	public void run(){
		printDoubleHash();
		//printChainHash();
	}
	
	private void printChainHash(){
		ChainHashTable<Integer> cHash = new ChainHashTable<Integer>(100);
		
		int[] keyList = Utils.genRandomInts(100, 1000);
		
		for (int i = 0; i < keyList.length; i++){
			cHash.insert(keyList[i]);
		}
		cHash.printHash();
	}

	private void printDoubleHash(){
		DoubleHashTable<Integer> dHash = new DoubleHashTable<Integer>(100);
		
		int[] keyList = Utils.genRandomInts(101, 1000);
		
		for (int i = 0; i < keyList.length; i++){
			dHash.insert(keyList[i], keyList[i]);
		}
		
		Integer val = 0;
		if ((val = dHash.find(10000)) == null){
			System.err.println("item not found");
		}else{
			System.out.println("found " + val);
		}
		
		dHash.printHash();
	}
	
	public static void main(String args[]){
		new test_hash().start();
	}
}
